Interprocess Communication with macOS by Hem Dutt

Interprocess Communication with macOS by Hem Dutt

Author:Hem Dutt
Language: eng
Format: epub
ISBN: 9781484270455
Publisher: Apress


Scripting Bridge

Scripting Bridge is a technology which makes it easy for a program written in Objective-C to communicate with scriptable applications.

Many applications on OS X are scriptable. A scriptable application must define an interface for responding to commands. This interface and its implementation must conform to an object model prescribed by the Open Scripting Architecture (OSA) that specifies the classes of scripting objects, the accessible properties of those objects, the inheritance and containment relationships of scripting objects, and the commands that the scriptable application responds to.

The OSA packages commands to scriptable applications as Apple events and uses the Apple Event Manager to dispatch those events and receive data in return.

AppleScript scripts have long been the principal way to communicate with scriptable applications. But an application can also send commands to a scriptable application and receive responses back to it.

The traditional way of doing this requires you to use the data structures and functions of the OSA framework to create and send Apple events, but this can be a very complex task.

Typical Cocoa applications, if not using Scripting Bridge, rely on including an AppleScript script in the application bundle and use Cocoa’s NSAppleScript class to execute the script as we have discussed in sections before.

Another way a Cocoa app interacts with scriptable applications is by using the NSAppleEventDescriptor class to create Apple events which they then send with Apple Event Manager routines.

However, both of these approaches are not straightforward for Cocoa developers not interested in AppleScripts.

The Scripting Bridge framework makes it possible to send and receive Apple events using Objective-C messages instead of AppleScript commands or Apple event descriptors.

For Cocoa programmers, Scripting Bridge provides a very simple model for controlling scriptable applications. It allows Cocoa programs to send and receive Apple events without requiring you to have detailed knowledge of the target application’s Apple event model.

Scripting Bridge integrates well with existing Objective-C code and works with standard Cocoa designs, such as key-value coding, target-action, and declared properties.

Other advantages of Scripting Bridge are 1.

It gives your application access to any scriptable feature of any available scriptable application.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.